const path = require('path');
const webpack = require('webpack');
const webpackBaseConfig = require("./config/base.js");
const webpackMerge = require('webpack-merge');
const OpenBrowserPlugin = require('open-browser-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
module.exports = function() {
  return webpackMerge(webpackBaseConfig(), {
    entry: {
      app: './app/index.js',
      vendors: './app/vendor.js'
    },
    devtool: false,
    output: {
      filename: '[name]-[hash].js',
      path: path.resolve(__dirname, 'dist/'),
      chunkFilename: 'test',
      library: 'libray',
      publicPath: '' //此处是打包是替换路径的
    },
    module: {
      rules: [

         {
          test: /\.scss$/,
          use: ExtractTextPlugin.extract({
            use: [
              {
                loader: "css-loader",
                options:{
                  minimize:true,//压缩代码
                  sourceMap:false//提供代码映射图
                }
              }, {
                loader: "sass-loader"
              }
            ],
            fallback: 'style-loader'
          })
        }
      ]
    },
    devServer:{
      contentBase:'./src',
      port:9000,
      inline:true,
      hot:true,
      compress:true,
      historyApiFallback:true
    },
    plugins: [
      new webpack.optimize.UglifyJsPlugin({
        compress: true
      }),
      new OpenBrowserPlugin({url:'http://localhost:9000'})
    ]
  })
}
